<%@ taglib prefix="page" uri="http://com.qipay/pagelib" %>
<%@ page language="java" import="com.qipay.admin.utils.SiteHelper" contentType="text/html;charset=utf-8" %>
<%@ page import="com.qipay.baas.model.Sp" %>
<%@ page import="com.qipay.admin.sp.vo.SpUserDTO" %>
<%@ page import="java.util.List" %>
<!doctype html>
<html>
<head>
    <jsp:include page="head.jsp"></jsp:include>
    <title>编辑SP信息</title>
</head>
<body class="devpreview hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <jsp:include page="nav.jsp"></jsp:include>
    <jsp:include page="left.jsp"></jsp:include>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Main content -->
        <%
            Sp cpChannel = (Sp) request.getAttribute("detail");
            List<SpUserDTO> spUserDTOS = (List<SpUserDTO>) request.getAttribute("spUsers");
            boolean isAdd = String.valueOf(request.getAttribute("isadd")).equals("1");
        %>
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box box-info">

                        <!-- /.box-header -->
                        <!-- form start -->
                        <form class="form-horizontal" action="save" method="POST" id="doc-vld-msg">
                            <input type="hidden" name="id" value="<%= isAdd?"":String.valueOf(cpChannel.getId())%>">
                            <div class="box-body" id="dvContent">

                                <div class="form-group">
                                    <label for="txtname" class="col-sm-2 control-label">SP名称：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtname" name="name" mush="1"
                                               value="<%= isAdd?"":cpChannel.getName()%>" placeholder="sp名称">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="txtname" class="col-sm-2 control-label">选择供号商：</label>
                                    <div class="col-sm-10">
                                        <select id="spUserName" name="spUserName" class="form-control">
                                            <% for (SpUserDTO s : spUserDTOS) {%>
                                            <option value="<%=s.getName()%>"
                                                <%if(s.getName().equals(cpChannel==null?"":cpChannel.getSpUserName())){%>
                                                    selected = "selected";
                                                    <%}%>><%= s.getSpUserName()%></option>
                                            <%}%>
                                        </select>
                                    </div>
                                </div>
<%--                                <div class="form-group">
                                    <label for="txtmchid" class="col-sm-2 control-label">商户ID：</label>
                                    <div class="col-sm-10">
                                        <input type="number" class="form-control" id="txtmchid" name="mchId"
                                               value="<%= isAdd?"":String.valueOf(cpChannel.getMchId())%>"
                                               placeholder="商户id">
                                    </div>
                                </div>--%>
                                <div class="form-group">
                                    <label for="txtservice" class="col-sm-2 control-label">服务：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtservice" name="service" mush="1"
                                               value="<%= isAdd?"":cpChannel.getService()%>" placeholder="服务">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="txtbank" class="col-sm-2 control-label">渠道：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtbank" name="bank" mush="1"
                                               value="<%= isAdd?"":cpChannel.getBank()%>" placeholder="银行名称">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="txtcardno" class="col-sm-2 control-label">回调IP白名单：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtcardno" name="cardNo"

                                               value="<%= isAdd?"":cpChannel.getCardNo()%>" placeholder="IP白名单">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="txtfactoryClassName" class="col-sm-2 control-label">工厂类名：</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="txtfactoryClassName"
                                               name="factoryClassName" mush="1"
                                               value="<%= isAdd?"":SiteHelper.getEmptyStr(cpChannel.getFactoryClassName())%>"
                                               placeholder="服务工厂类名">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="ddlState" class="col-sm-2 control-label">状态：</label>
                                    <div class="col-sm-10">
                                        <select id="ddlState" name="state">
                                            <option value="0"><%= SiteHelper.getChannelStateString((byte) 0)%>
                                            </option>
                                            <option value="1"><%= SiteHelper.getChannelStateString((byte) 1)%>
                                            </option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <!-- /.box-body -->
                            <div class="box-footer">
                                <button type="button" class="btn btn-primary btn-sm borderNone" onclick="window.history.back()">返回
                                </button>
                                <button type="button" class="btn btn-success btn-sm borderNone" id="btnSearch">确 定</button>
                            </div>
                            <!-- /.box-footer -->
                        </form>
                    </div>
                    <!-- /.box -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <%--<jsp:include page="foot.jsp"></jsp:include>--%>
</div>
<script src="<%= request.getAttribute("StaticHost") %>/js/fastclick.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/adminlte.min.js"></script>
<script>
    $(function () {
        var channelState = parseInt("<%= cpChannel !=null&&cpChannel.getState()!=null?cpChannel.getState().byteValue():0%>", 10);
        if (channelState > 0) {
            $("#ddlState").val(channelState);
        }
        $("#btnSearch").on("click", function () {
            var isGo = checkInputMust("dvContent");
            if (isGo) {
                $("#doc-vld-msg")[0].submit();
            }
        });
    })


</script>
</body>
</html>

